package com.gtw.modules.api.controller;

import com.gtw.common.annotation.LoginUserApi;
import com.gtw.common.utils.PageUtils;
import com.gtw.common.utils.Query;
import com.gtw.common.utils.R;
import com.gtw.modules.entity.TbClearingDetails;
import com.gtw.modules.entity.TbUser;
import com.gtw.modules.sys.service.SysTbClearingDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/** 收益明细
 * Created by wuye on 2018/3/27.
 */
@RestController
@RequestMapping("/api/clearingdetails")
public class TbClearingDetailsController {

    @Autowired
    private SysTbClearingDetailsService sysTbClearingDetailsService;


    /**
     * 查询列表
     * @return
     */
    @RequestMapping("/queryList")
    public R queryList(@RequestParam Map<String, Object> params, @LoginUserApi TbUser tbUser){
        params.put("userid",tbUser.getUserId());
        Query query = new Query(params);
        List<TbClearingDetails> clearingDetailsList = sysTbClearingDetailsService.queryList(query);
        int total = sysTbClearingDetailsService.queryTotal(query);
        PageUtils pageUtil = new PageUtils(clearingDetailsList, total, query.getLimit(), query.getPage());

        return R.ok().put("data", pageUtil);
    }
}
